<%@page import="com.swlz.entity.Role"%>
<%@page import="com.swlz.entity.User"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>


<html>
<head>
<title>修改产品</title>
<jsp:include page="/admin/head.jsp" />
</head>
<body>
	<jsp:include page="/admin/header.jsp" />
	<jsp:include page="/admin/left-menu.jsp"><jsp:param
			value="1" name="index" /></jsp:include>
	<jsp:include page="/admin/footer.jsp" />



	<!--中间-->
	<section>
		<nav aria-label="breadcrumb">
			<ol class="breadcrumb">
				<li class="breadcrumb-item">管理首页</li>
				<li class="breadcrumb-item">产品中心</li>
				<li class="breadcrumb-item">产品管理</li>
				<li class="breadcrumb-item active">修改产品</li>
			</ol>
		</nav>

		<div class="card container-md">
			<div class="card-body">
				<form name="updateForm" action="admin/upload.let" enctype="multipart/form-data" method="POST" >
					
					<input type="hidden" name="productId" value="${product.productId }" />

					<div class="form-group row">
						<label class="col-sm-3 col-form-label text-right"><b
							class="text-danger">*</b>商品名</label>
						<div class="col-sm-9">

							<input required="required" name="productName" type="text"
								class="form-control" value="${product.productName}">

						</div>
					</div>



					<div class="form-group row">
						<label class="col-sm-3 col-form-label text-right"><b
							class="text-danger">*</b>库存</label>
						<div class="col-sm-9">

							<input required="required" name="productNum" type="text"
								class="form-control" value="${product.productNum}">
						</div>
					</div>



					<div class="form-group row">
						<label class="col-sm-3 col-form-label text-right"><b
							class="text-danger">*</b>折扣价</label>
						<div class="col-sm-9">
							<input name="productPrice2" type="tel" class="form-control"
								value="${product.productPrice2 }">
						</div>
					</div>



					<div class="form-group row">
						<label class="col-sm-3 col-form-label text-right">产品颜色</label>
						<div class="col-sm-9">
							<input name="productColors" type="tel" class="form-control"
								value="${product.productColors }">
						</div>
					</div>

					<div class="form-group row">
						<label class="col-sm-3 col-form-label text-right">产品图片</label>
						<div class="col-sm-9">

							<div class="wrap">
								<input id="fileupload" class="file" type="file"
									name="productImgs" onChange="preview(this)" accept="image/*" />
							</div>
							<div id="preview">
								<img  alt="图片加载失败" src="${product.productImgs}"
									width="150px" height="150px" class="img">
							</div>
							
						</div>
					</div>

					<div class="form-group row">
						<div class="col-sm-9 offset-sm-3">
							<button class="btn btn-primary" type="button"
								onclick="history.go(-1);">返回</button>
							<button class="btn btn-danger" type="submit">
								<i class="fa fa-edit mr-2"></i>修改
							</button>
						</div>
					</div>

				</form>
			</div>
		</div>
	</section>

	 <script type="text/javascript">  
                 function preview(file){  
                        var div = $(file).parent().next();
                        if(file.files&&file.files[0]){  
                             var reader=new FileReader(); 

                             reader.onload=function(evt){  

                                div.html('<img  width="150" height="150" src="'+evt.target.result+'"/>');   
                             }  
                                reader.readAsDataURL(file.files[0]);  

                            }else{  
                            prevDiv.innerHTML='<div class="img" width="150" height="150" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader">';   
                          }  


             }  
        </script>
        
</body>
</html>
